
import java.awt.Font;
import java.awt.event.WindowEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class DeleteUserFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JComboBox<String> cmbbxUser; 

	/**
	 * Create the frame.
	 */
	public DeleteUserFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 350, 200);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("用户");
		lblNewLabel.setFont(new Font("Dialog", Font.BOLD, 20));
		lblNewLabel.setBounds(42, 12, 47, 37);
		contentPane.add(lblNewLabel);
		
		cmbbxUser = new JComboBox<String>();
		cmbbxUser.setFont(new Font("Dialog", Font.BOLD, 20));
		cmbbxUser.setBounds(107, 20, 143, 29);
		contentPane.add(cmbbxUser);
		
		JButton btnDelete = new JButton("删除");
		btnDelete.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String name =(String)cmbbxUser.getSelectedItem();
				Launcher.deleteByName(name);
				dispose();
				Launcher.showDeleteUserFrame();
			}
		});
		btnDelete.setFont(new Font("Dialog", Font.BOLD, 20));
		btnDelete.setBounds(42, 119, 95, 25);
		contentPane.add(btnDelete);
		
		JButton btnReturn = new JButton("返回");
		btnReturn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
				Launcher.showMainFrame();
			}
		});
		btnReturn.setFont(new Font("Dialog", Font.BOLD, 20));
		btnReturn.setBounds(155, 119, 95, 25);
		contentPane.add(btnReturn);
	}
	
	public void setNameList(String[] names){
		cmbbxUser.setModel(new DefaultComboBoxModel<String>(names));
	}
	
	protected void processWindowEvent(WindowEvent e){
		if(e.getID() == WindowEvent.WINDOW_CLOSING){
		}else{
			super.processWindowEvent(e);
		}
	}
}
